class Trie {
public:
    /** Initialize your data structure here. */
    Trie()
    {}

    /** Inserts a word into the trie. */
    void insert(string word)
    {
        hash[word] = word.size();
    }

    /** Returns if the word is in the trie. */
    bool search(string word)
    {
        if (hash[word] == 0) return false;
        return true;
    }

    /** Returns if there is any word in the trie that starts with the given prefix. */
    bool startsWith(string prefix)
    {
        for (auto [e, x] : hash)
        {
            if (x < prefix.size()) continue;
            int i;
            for (i = 0; i < prefix.size(); i++)
            {
                if (e[i] != prefix[i]) break;
            }
            if (i == prefix.size()) return true;
        }
        return false;
    }
private:
    map<string, int> hash;
};

/**
 * Your Trie object will be instantiated and called as such:
 * Trie* obj = new Trie();
 * obj->insert(word);
 * bool param_2 = obj->search(word);
 * bool param_3 = obj->startsWith(prefix);
 */